'use strict';

module.exports = appInfo => {
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1514183946804_9457';

  // add your config here
  config.middleware = [];

  // operator login password secret key
  config.operator_secret = process.env.operator_secret;

  // 文件上传路径
  config.upload_path = process.env.upload_path;

  // mongodb
  config.mongoose = {
    url: process.env.mongo_uri,
    options: {
      mongos: process.env.mongos === 'true'? true:false
    },
  };

  // 支付
  config.pay = {
    url: process.env.pay_endpoint,
    options: {
      secret: process.env.pay_secret,
    },
  };

  // 短信
  config.sms = {
    url: process.env.sms_endpoint,
    options: {
      ykqj: {
        signatureid: 4,
        templates: {
          cash: 300182,
          gift: 300183,
          virtual: 300184,
        },
      },
      qyl: {
        signatureid: 5,
        templates: {
          cash: 300182,
          gift: 300183,
          virtual: 300184,
        },
      },
      qsjs: {
        signatureid: 8,
        templates: {
          cash: 300182,
          gift: 300183,
          virtual: 300184,
        },
      },
    },
  };

  config.redis = {
    client: {
      port: process.env.redis_port,
      host: process.env.redis_host,
      password: process.env.redis_password,
      db: process.env.redis_db,
    },
  };

  config.mysql = {
    client: {
      host: process.env.mysql_host,
      port: process.env.mysql_port,
      user: process.env.mysql_user,
      password: process.env.mysql_password,
      database: process.env.mysql_database,
    },
    app: true,
    agent: false,
  };

  // 日志输出地址
  config.logger = {
    dir: process.env.log_dir,
  };

  // mta
  config.mta = {
    appId: 500411806,
    secretKey: 'a4bdc28630cb1b924b7a8382cad733d8',
    ctrCustomUrl: 'http://mta.qq.com/h5/api/ctr_custom', // 自定义事件
    ctrPageUrl: 'http://mta.qq.com/h5/api/ctr_page', // 页面排行
  };
  return config;
};
